<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>滚轮事件</title>
    <style>
        *{
            transition: 1s;
        }
        #box1{
            width: 100px;
            height: 100px;
            background-color: rgb(1, 187, 125);
        }
    </style>
</head>
<body>
    <div id="box1"></div>
</body>
</html>
<script>
    /*
        滚轮时 div 变长
    */

    var box1 = document.getElementById("box1");
    var wit=100;
    box1.onwheel = function(event){

        /*
            event.wheelDelta    ⭐⭐📌
                可以获取鼠标滚轮 滚动方向
                向上滚= 120  向下滚= -120
                wheelDelta 这个值不看大小，只看正负

            event.detail        ⭐⭐📌火狐
                在火狐中使用event.detail 获取滚动方向
                向上滚= -3   向下滚= 3
         */
         
        // alert(box1.style.height);
        if(parseInt(box1.style.height) < 60){
            wit=60;
            box1.style.height = wit+"px";
            // alert(box1.style.height);
        }
        if (event.wheelDelta > 0 || event.detail <0) { //当滑轮向上滚动时  
            wit= wit-10;
            box1.style.height = wit+"px"; 
        }else{ //当滑轮向下滚动时  
            wit= wit+10;
            box1.style.height = wit+"px"; 
        }
        // alert(wit);
        
    }
</script>